<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   design_blank
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<div class="page-title title-buttons">
    <h1><?php echo $this->__('Compare Products') ?></h1>
    <a href="#" onclick="window.print(); return false;"><?php echo $this->__('Print This Page') ?></a>
</div>
<?php $_total=$this->getItems()->getSize() ?>
<?php if($_total): ?>
    <table class="data-table" id="product_comparison">
	   <?php $_i=0 ?>
	  <?php foreach($this->getItems() as $_item): ?>
	        <?php if($_i++%10==0): ?>
	            <col width="1" />
	        <?php endif; ?>
	            <col width="<?php echo floor(100/$_total); ?>%" />
    <?php endforeach; ?>
<?php if ($_total>2): ?>
<thead>
            <tr>
	         <?php $_i=0 ?>
		     <?php foreach($this->getItems() as $_item): ?>

                <?php if($_i++%10==0): ?>
                    <th>&nbsp;</th>
                <?php endif; ?>
                <td class="a-right"><a href="#" onclick="setLocation('<?php echo $this->helper('catalog/product_compare')->getRemoveUrl($_item) ?>') ;window.opener.location.reload();" title="<?php echo $this->__('Remove Product') ?>"><img src="<?php echo $this->getSkinUrl('images/list_remove_btn.gif') ?>" alt="<?php echo $this->__('Remove Product') ?>" /></a></td>
            <?php endforeach; ?>

            </tr>
        </thead>
<?php endif ?>
        <tbody>
            <tr>
            <?php $_i=0 ?>
            <?php foreach($this->getItems() as $_item): ?>
                <?php if($_i++%10==0): ?>
                    <th class="label">&nbsp;</th>
                <?php endif; ?>
                <td>
                    <a class="product-image" rel="nofollow" href="#" onclick="setPLocation('<?php echo $_item->getProductUrl() ?>', true)" title="<?php echo $this->htmlEscape($_item->getName()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'small_image')->resize(125, 125); ?>" width="125" height="125" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" title="<?php echo $this->htmlEscape($_item->getName()) ?>" /></a>
                    <h2 class="product-name"><a href="#" onclick="setPLocation('<?php echo $_item->getProductUrl() ?>', true)" title="<?php echo $this->htmlEscape($_item->getName()) ?>"><?php echo $this->htmlEscape($_item->getName()) ?></a></h2>
                    <?php echo $this->getReviewsSummaryHtml($_item, 'short') ?>
                    <?php echo $this->getPriceHtml($_item, true) ?>
                    <?php if($_item->isSaleable()): ?>
						<p><button type="button" class="button" onclick="setPLocation('<?php echo $this->helper('catalog/product_compare')->getAddToCartUrl($_item) ?>', true)"><span><?php echo $this->__('Add to Cart') ?></span></button></p>
                    <?php else: ?>
						<p class="availability"><span class="out-of-stock"><?php echo $this->__('Out of stock') ?></span></p>
					<?php endif; ?>
                    <?php if ($this->helper('wishlist')->isAllow()) : ?>
                    <p><a href="#" rel="nofollow" onclick="setPLocation('<?php echo $this->helper('catalog/product_compare')->getAddToWishlistUrl($_item) ?>', true)"><?php echo $this->__('Add to My Wishlist') ?></a></p>
                    <?php endif; ?>
                </td>
            <?php endforeach; ?>
            </tr>
        </tbody>
        <tbody>
        <?php foreach ($this->getAttributes() as $_attribute): ?>
            <tr>
                <?php $_i=0 ?>
                <?php foreach($this->getItems() as $_item): ?>
                <?php if($_i++%10==0): ?>
                <th class="label"><span class="nobr"><?php echo $this->__($_attribute->getFrontendLabel()) ?></span></th>
                <?php endif; ?>
                <td>
                    <?php switch ($_attribute->getAttributeCode()) {
                        case "price": ?>
                            <?php echo $this->getPriceHtml($_item, true) ?>
                            <?php break;
                        case "small_image": ?>
                            <img src="<?php echo $this->helper('catalog/image')->init($_item, 'small_image')->resize(125, 125); ?>" width="125" height="125" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" />
                            <?php break;
                        default: ?>
                            <?php echo nl2br($this->getProductAttributeValue($_item, $_attribute)) ?>
                            <?php break;
                    } ?>
                </td>
                <?php endforeach; ?>
            </tr>
        <?php endforeach; ?>
        </tbody>
        <tbody>
                <tr>
                <?php $_i=0 ?>
                <?php foreach($this->getItems() as $_item): ?>
                <?php if($_i++%10==0): ?>
                 <th class="label">&nbsp;</th>
                <?php endif; ?>
                <td class="data">
                    <?php echo $this->getPriceHtml($_item) ?>
                    <?php if($_item->isSaleable()): ?>
                        <p><button type="button" class="button" onclick="setPLocation('<?php echo $this->helper('catalog/product_compare')->getAddToCartUrl($_item) ?>', true)"><span><?php echo $this->__('Add to Cart') ?></span></button></p>
                    <?php else: ?>
                        <p class="availability"><span class="out-of-stock"><?php echo $this->__('Out of stock') ?></span></p>
                    <?php endif; ?>
                    <?php if ($this->helper('wishlist')->isAllow()) : ?>
                        <p><a href="#" rel="nofollow" onclick="setPLocation('<?php echo $this->helper('catalog/product_compare')->getAddToWishlistUrl($_item) ?>', true)"><?php echo $this->__('Add to Wishlist') ?></a></p>
                    <?php endif; ?>
                </td>
                <?php endforeach; ?>
            </tr>
        </tbody>
    </table>
    <div class="buttons-set">
        <button type="button" class="button" onclick="window.close();"><span><?php echo $this->__('Close Window') ?></span></button>
    </div>
    <script type="text/javascript">decorateTable('product_comparison');</script>
<?php else: ?>
    <script type="text/javascript">window.close();</script>
<?php endif; ?>
